<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" media="all" />
	</head>
	<body style="padding: 10px;">
		<form class="layui-form layui-form-pane" action="" lay-filter="formAddRecord">
			<div class="layui-form-item">
				<label class="layui-form-label">交往日期</label>
				<div class="layui-input-inline">
					<input type="text" name="reDate" class="layui-input" id="test1" placeholder="请输入日期" lay-verify='required'>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">地点</label>
				<div class="layui-input-inline">
					<input type="text" name="reSite" placeholder="请输入地点" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">概要信息</label>
				<div class="layui-input-inline">
					<input type="text" name="reOutline" placeholder="请输入概要信息" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">详细信息</label>
				<div class="layui-input-inline">
					<input type="text" name="reDetail" placeholder="请输入详细信息" autocomplete="off" class="layui-input" lay-verify='required'>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">备注信息</label>
				<div class="layui-input-inline">
					<input type="text" name="reRemark" placeholder="请输入备注信息" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">客户编号</label>
				<div class="layui-input-inline">
					<input type="text" name="cusNo" placeholder="请输入客户编号" autocomplete="off" class="layui-input" lay-verify='required'>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitAddRecord">立即添加</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>

		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form', 'jquery', 'laydate'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				var laydate = layui.laydate;

				//常规用法
				laydate.render({
					elem: '#test1'
				});

				//监听提交
				form.on('submit(submitAddRecord)', function(d) {
					// d.field //表单的数据
					if (form.verify()) {
						$.ajax({
							url: 'http://localhost:8080/record/addRecord',
							type: 'POST', //提交方式，有POST、GET等等
							dataType: 'JSON', //后台返回数据格式
							data: d.field, //提交到后台的数据
							success: function(obj) { //执行成功回调函数，返回一个obj对象
								//执行ajax提交成功后处理代码
								layer.msg(obj.msg)
								parent.table.reload('tblRecord')
								var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭
							}
						})
					}
					return false; //阻止form提交刷新
				});
			})
		</script>
	</body>
</html>
